package com.xbongbong.paas.service.impl;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.xbongbong.paas.pojo.vo.FeeLogInfoVO;
import com.xbongbong.paas.redis.PaasRedisHelper;
import com.xbongbong.paas.redis.RedisPrefixConstant;
import com.xbongbong.paas.redis.RedisTimeConstant;
import com.xbongbong.paas.service.FeeLogService;
import com.xbongbong.paas.toolbox.exception.XbbException;
import com.xbongbong.paas.toolbox.util.BeanUtil;
import com.xbongbong.paas.toolbox.util.CollectionsUtil;
import com.xbongbong.paas.toolbox.util.DateTimeUtil;
import com.xbongbong.paas.toolbox.util.StringUtil;
import com.xbongbong.paas.toolbox.wrap.BaseDTO;
import com.xbongbong.pro.enums.ValueAddedTypeEnum;
import com.xbongbong.saas.enums.XbbRefTypeEnum;
import com.xbongbong.sys.domain.entity.FeeEntity;
import com.xbongbong.sys.domain.entity.FeeLogEntity;
import com.xbongbong.sys.model.FeeLogModel;
import com.xbongbong.sys.model.FeeModel;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Objects;

/**
 *
 * @author youli.chen
 * @date 2019/2/15 10:37
 * @since v1.0
 * @version v1.0
 */
@Service("feeLogService")
public class FeeLogServiceImpl implements FeeLogService {

    @Resource
    private FeeLogModel feeLogModel;

    /**
     * 支付宝支付之后，回调最新的订单信息
     *
     * @param baseDTO
     * @return
     * @throws XbbException
     */
    @Override
    public FeeLogInfoVO getDingTalkPayInfo(BaseDTO baseDTO) throws XbbException {
        FeeLogEntity feeLogEntity = feeLogModel.getDingTalkPayInfo(baseDTO.getCorpid());
        FeeLogInfoVO feeLogInfoVO = new FeeLogInfoVO();
        if(feeLogEntity != null){
            BeanUtil.copyProperties(feeLogEntity, feeLogInfoVO);
        }
        return feeLogInfoVO;
    }

    /**
     * 判断工单是否已过期
     *
     * @param corpid 公司ID
     * @return 否已过期 true -> 过期 false -> 未过期
     * @throws XbbException 异常
     */
    @Override
    public Boolean workOrderV2PastDue(String corpid) throws XbbException {
       return feeLogModel.workOrderV2PastDue(corpid);
    }
}
